import React from 'react';
import { Button,Checkbox, Row,Col,Select,Form, Input,DatePicker,Table,Tag,Switch } from 'antd';
import './addgratis.scss'
import * as service from '../../../../../api/tzp'
import { useNavigate } from 'react-router-dom';
import { useParams } from 'react-router-dom';


function Addgratis(props: any) {
    var [form] = Form.useForm()
    let params = useParams()
    console.log("数据",params);
        
    var navigate = useNavigate()
    var onFinish = async (formvalues: any) => {
        var time = new Date()
        console.log(formvalues);
        console.log(formvalues.rights[0]);
        var res = await service.add_vipgrade({grade:formvalues.grade,gradename:formvalues.gradename,value:formvalues.value,rights:formvalues.rights[0],packs:formvalues.packs,flag:1,time:time})
        console.log(res);
        navigate('/index/gratisvip')
    }
    return (
        <div className='addgratis'>
            <div className='title-box'>
                <div className='title-top'>用户管理 / 免费会员等级管理 / 配置会员等级</div>
                <div className='title-bottom'>配置会员等级</div>
            </div>
            <div className="addgratis-list">

                <Form
                    // className='from-box'
                    form={form}
                    // labelCol={{ span: 4 }}
                    wrapperCol={{ span: 14 }}
                    layout="horizontal"
                    style={{ maxWidth: 600 }}
                    onFinish={onFinish}
                >
                    <Form.Item
                        label="会员等级"
                        name="grade"
                    >
                        <Select
                            // defaultValue="LV1"
                            placeholder='请选择---'
                            style={{ width: 200 }}
                            options={[
                                { value: 'LV1', label: 'LV1' },
                                { value: 'LV2', label: 'LV2' },
                                { value: 'LV3', label: 'LV3' },
                                { value: 'LV4', label: 'LV4' },
                                { value: 'LV5', label: 'LV5' },
                                { value: 'LV6', label: 'LV6' },
                            ]}
                        />
                    </Form.Item>
                    <Form.Item
                        label="等级名称"
                        name="gradename"
                    >
                        <Select
                            // defaultValue="普通会员"
                            placeholder='请选择---'
                            style={{ width: 200 }}
                            options={[
                                { value: '普通会员', label: '普通会员' },
                                { value: '银卡会员', label: '银卡会员' },
                                { value: '金卡会员', label: '金卡会员' },
                                { value: '白金会员', label: '白金会员' },
                                { value: '铂金会员', label: '铂金会员' },
                                { value: '至尊会员', label: '至尊会员' },
                            ]}
                        />
                    </Form.Item>
                    <Form.Item
                        label="升级条件"
                    >
                        <Form.Item
                            label="累计消费"
                            name="consume"
                        >
                            <Input placeholder='请输入' />
                        </Form.Item>
                        <Form.Item

                            label="成长数值"
                            name="value"
                        >
                            <Input placeholder='请输入' />
                        </Form.Item>
                    </Form.Item>

                    <Form.Item name="rights" label="等级权益" style={{marginTop:'-30px'}}>
                        <Checkbox.Group style={{ width: '100%' }}
                        >
                            <Row>
                                <Col span={20} style={{marginBottom:10 ,marginTop:5}}>
                                    <Checkbox value="专属赠品">专属赠品</Checkbox>
                                </Col>
                                <Col span={20} style={{marginBottom:10}}>
                                    <Checkbox value="积分翻倍">积分翻倍</Checkbox>
                                </Col>
                                <Col span={20} style={{marginBottom:10}}>
                                    <Checkbox value="全场包邮">全场包邮</Checkbox>
                                </Col>
                                <Col span={20} style={{marginBottom:10}}>
                                    <Checkbox value="商品折扣">商品折扣</Checkbox>
                                </Col>
                                <Col span={20} >
                                    <Checkbox value="特卖专享">特卖专享</Checkbox>
                                </Col>
                            </Row>
                        </Checkbox.Group>
                    </Form.Item>
                    <Form.Item
                        label="升级礼包"
                        name="packs"
                    >
                        <Select
                            // defaultValue="10元优惠券"
                            placeholder='请选择---'
                            style={{ width: 200 }}
                            options={[
                                { value: '10元优惠券', label: '10元优惠券' },
                                { value: '新用户100元通用券', label: '新用户100元通用券' },
                                { value: '7折优惠券', label: '7折优惠券' },
                                { value: '8折优惠券', label: '8折优惠券' },
                            ]}
                        />
                    </Form.Item>
                    <Form.Item  >
                        <Button htmlType="submit">提交</Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    );
}

export default Addgratis;